package modelLayer;

import java.util.Date;
import java.util.List;

public class Invoice {
	private int invoiceNo;
	private String paymentDate;
	private Customer customer;
	private List<SalesOrder> salesOrders;

	/**
	 * Constructor that constructs the object before it is inserted into the database. 
	 *
	 * @param order
	 */
	public Invoice(SalesOrder order) {
		setCustomer(order.getCustomer());
		if (order.getCustomer().getIsPrivate() == true) {
			/*int dDay = d.getDay();
			d.setDate(dDay + 7);*/
			setPaymentDate(order.getOrderDate()); //evt. plus 7 dage.
		} else {
			setPaymentDate(order.getOrderDate()); //evt. plus 30 dage.
		}
		addSalesOrder(order);
	}

	/**
	 * Constructor that constructs the object from data retrieved from the database.
	 */
	public Invoice() {}
	
	public void addSalesOrder(SalesOrder order) {
		salesOrders.add(order);
	}

	/**
	 * @return the invoiceNo
	 */
	public int getInvoiceNo() {
		return invoiceNo;
	}

	/**
	 * @param invoiceNo the invoiceNo to set
	 */
	public void setInvoiceNo(int invoiceNo) {
		this.invoiceNo = invoiceNo;
	}

	/**
	 * @return the paymentDate
	 */
	public String getPaymentDate() {
		return paymentDate;
	}

	/**
	 * @param paymentDate the paymentDate to set
	 */
	public void setPaymentDate(String paymentDate) {
		this.paymentDate = paymentDate;
	}

	/**
	 * @return the customer
	 */
	public Customer getCustomer() {
		return customer;
	}

	/**
	 * @param customer the customer to set
	 */
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	/**
	 * @return the salesOrders
	 */
	public List<SalesOrder> getSalesOrders() {
		return salesOrders;
	}

	/**
	 * @param salesOrders the salesOrders to set
	 */
	public void setSalesOrders(List<SalesOrder> salesOrders) {
		this.salesOrders = salesOrders;
	}
}
